<?php defined('SYSPATH') or die('No direct script access.');
 


class Controller_Main extends Controller_GeneralClass {
 
    
    
    public function action_index()
    {
        
        
               
        
        $content =Request::factory('maincontent')->execute();;
        
        $this->template->content=$content;
        
        
    }
    
    public function action_productsAll()
    {
        
        $productsAll = new Model_ForDB();
        
        
        
        $content = View::factory('productsAll');
        $content->products=$productsAll->getProducts();
        
                
        $this->template->content=$content;
        
        
        
    }
    
    
    
    public function action_product()
    {
        
        // id вимагає  створення роута
        $id = $this->request->param('id');
        //Request::current()->param('id');
        
        $product = new Model_ForDB();
        $theFiles= new Model_ForFile();
        
        $content = View::factory('product');
        $content->product=$product->getProduct($id);
        $content->theFiles=$theFiles->getImgFiles('public/images/goods/'.$id);
        
        $this->template->content=$content;
   
        
        
    }
    
    public function action_prodGroup()
    {
        
        // id вимагає  створення роута
        $id1 = $this->request->param('id1');
        $id2 = $this->request->param('id2');
        //Request::current()->param('id');
        
        $prodGroup = new Model_ForDB();
        
        
        $content = View::factory('prodGroup');
        if ($id2){
          $content->prodGroup=$prodGroup->getProductsInProdSubGroup($id1,$id2);   
        }else{
          $content->prodGroup=$prodGroup->getProductsInProdGroup($id1);  
        }
        
        
        
        $this->template->content=$content;
   
        
        
    }
    
    public function action_buy()
    {
        
        // id вимагає  створення роута
        $id = $this->request->param('id');
        //Request::current()->param('id');
        
        $product = new Model_ForDB();
        
        
        $content = View::factory('buy');
        $content->product=$product->getProduct($id);
        
        
        $this->template->content=$content;
   
        
        
    }
    
    
    
    
    

 
} // End Page
        